
const { ccclass, property, executionOrder, menu } = cc._decorator;

@ccclass
@menu("屏幕适配/动态大小")
export default class ToScreenSize extends cc.Component {
    @property(cc.Boolean)
    adjustWidth = true
    @property(cc.Boolean)
    adjustHeight = false

    onLoad() {
        let v = cc.winSize
        if (this.adjustWidth) {
            let delta = cc.Canvas.instance.designResolution.width - this.node.width;
            this.node.setContentSize(cc.size(v.width - delta, this.node.getContentSize().height))
        }
        if (this.adjustHeight) {
            let delta = cc.Canvas.instance.designResolution.height - this.node.height;
            this.node.setContentSize(cc.size(this.node.getContentSize().width, v.height - delta))
        }
    }
}
